package com.etung.iot.demo.configs;
import com.etung.iot.demo.mqtt.EmqxClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MqttClientConfiguration {

    @Autowired
    private MqttConfig mqttConfig;

    @Bean
    EmqxClient mqttClient(){
        EmqxClient client = new EmqxClient(mqttConfig.getClientId(),
                mqttConfig.getUsername(),
                mqttConfig.getPassword(),
                mqttConfig.getHostUrl(),
                mqttConfig.getTimeout(),
                mqttConfig.getKeepalive(),
                mqttConfig.isClearSession()
        );
        return client;
    }
}
